In [1]:
import graphlab
In [2]:
song_data = graphlab.SFrame('song_data.gl/')
In [3]:
song_data.head()
Out[3]:
In [4]:
graphlab.canvas.set_target('ipynb')
In [5]:
song_data['song'].show()
In [6]:
users = song_data['user_id'].unique()
In [8]:
len(users)
Out[8]:
In [9]:
train_data, test_data = song_data.random_split(.8, seed=0)
In [12]:
popularity_model = graphlab.popularity_recommender.create(train_data, user_id='user_id', item_id='song')
In [13]:
popularity_model.recommend(users=[users[0]])
Out[13]:
In [14]:
personalized_model = graphlab.item_similarity_recommender.create(train_data, user_id='user_id', item_id='song')
In [15]:
personalized_model.recommend(users=[users[0]])
Out[15]:
In [16]:
personalized_model.recommend(users=[users[1]])
Out[16]:
In [20]:
personalized_model.get_similar_items(['Do I - Luke Bryan'])
Out[20]:
In [25]:
%matplotlib inline
model_performance = graphlab.recommender.util.compare_models(test_data, [popularity_model, personalized_model], user_sample=0.05)
In [ ]: